<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">

    <title>Profile</title>
    <link href="/public/js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
    <link href="/public/js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
    <link rel="stylesheet" href="/public/js/data-tables/DT_bootstrap.css" />

    <link href="/public/js/iCheck/skins/flat/red.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/flat/green.css" rel="stylesheet">
    <?php $this->load->view('library/header');?>
</head>

<body class="sticky-header">

<section>
    <?php $this->load->view('library/left');?>

    <!-- main content start-->
    <div class="main-content" >

        <?php $this->load->view('library/top');?>

        <!-- page heading start-->
        <!--<div class="page-heading">-->
        <!--Page Tittle goes here-->
        <!--</div>-->
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper">

            <div class="row">
                <div class="col-md-12">
                    <div class="panel">
                        <header class="panel-heading">
                            供应商信息
                            <span class="tools pull-right">
                                        <a class="fa fa-chevron-down" href="javascript:;"></a>
                                     </span>
                        </header>
                        <div class="panel-body">
                            <ul class="row p-info">
                                <li class="col-md-6">
                                    <div class="title">供应商：</div>
                                    <div class="desk"><?php echo $supp_info['suppliers_name'];?></div>
                                </li>
                                <li class="col-md-6">
                                    <div class="title">采购数量：</div>
                                    <div class="desk"><?php echo $supp_info['purchase_number'];?></div>
                                </li>
                                <li class="col-md-6">
                                    <div class="title">批次状态：</div>
                                    <div class="desk">
                                        <?php if ($purchase_order['po_status'] == 1) :?>
                                            等待采购
                                        <?php elseif ($purchase_order['po_status'] == 2) :?>
                                            采购中
                                        <?php elseif ($purchase_order['po_status'] == 3) :?>
                                            采购完成
                                        <?php endif;?>
                                    </div>
                                </li>
                                <li class="col-md-6">
                                    <div class="title">错误状态：</div>
                                    <div class="desk">
                                        <?php if ($purchase_order['is_wrong'] == 1) :?>
                                            异常批次
                                        <?php else:?>
                                            正常批次
                                        <?php endif;?>
                                    </div>
                                </li>
                                <li class="col-md-6">
                                    <div class="title">备注信息：</div>
                                    <div class="desk" style="line-height: 24px; margin: 10px 0;">
                                        <?php echo $purchase_order['po_info'];?>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel">
                        <header class="panel-heading">
                            采购商品
                            <span class="tools pull-right">
                                <?php if ($purchase_order['po_status'] == 1) :?>
                                    <a href="<?php echo base_url("purchase/operate/step/batch_purc_in/po_id/{$purchase_order['po_id']}");?>" data-toggle="modal" class="btn btn-info a-ajax">设为采购中</a>
                                <?php endif;?>
                                <a class="fa fa-chevron-down" href="javascript:;"></a>
                            </span>
                        </header>
                        <div class="panel-body">
                            <section id="unseen">
                                <table class="table table-bordered table-striped table-condensed">
                                    <thead>
                                    <tr>
                                        <th width="10%">商品图片</th>
                                        <th width="15%" >商品货号/供应商货号</th>
                                        <th width="15%" class="numeric">SKU属性</th>
                                        <th class="numeric">采购数量</th>
                                        <th class="numeric">入库数量</th>
                                        <th class="numeric">采购金额</th>
                                        <th width="15%" class="numeric">最后入库时间</th>
                                        <th width="10%" class="numeric">SKU操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php if ($goods_sku):?>
                                        <?php foreach ($goods_sku as $goods_id => $item) :?>
                                            <tr>
                                            <td class="center" rowspan="<?php echo count($item['sku']);?>"><img style="width: 80px;" src="<?php echo $item['original_img'];?>" /></td>
                                            <td  rowspan="<?php echo count($item['sku']);?>"><?php echo $item['goods_sn'];?><br />

                                                <span style="color: #990f40;"><?php echo $item['supp_sn']; ?></span>
                                            </td>

                                            <?php $i = 1; foreach ($item['sku'] as $sk => $sku) : ?>
                                                <?php if ($i > 1):?>
                                                    <tr >
                                                <?php endif;?>
                                                <td>
                                                    <?php echo $sku['sku_sn'];?><br />
                                                    <span style="color: #389930;"><?php echo  $sku['sl_title'] ? "货架位：{$sku['sl_title']}" : ''; ?></span>
                                                </td>
                                                <td><?php echo $sku['purchase_number'];?></td>
                                                <td><?php echo $sku['storage_number'];?></td>
                                                <td><?php echo $sku['purc_price'];?></td>
                                                <td><?php echo date('Y-m-d H:i:s', $sku['update_time']);?></td>
                                                <td>
                                                    <a class="btn btn-xs btn-info input-type-multiple" data-sn="<?php echo $sku['sku_sn'];?>" href="<?php echo base_url("purchase/in_storage/sku_id/{$sk}/supp_id/{$supp_info['suppliers_id']}/sgs_id/".intval($sku['sgs_id']));?>">入库</a>
                                                    <a class="btn btn-xs btn-info input-type-m" data-sn="<?php echo $sku['sku_sn'];?>" href="<?php echo base_url('purchase/print_code/sku_id/'. $sk); ?>">打印条码</a>
                                                </td>
                                                </tr>
                                            <?php endforeach;?>
                                        <?php endforeach;?>
                                    <?php endif;?>
                                    </tbody>
                                </table>
                            </section>
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel">
                        <form action="<?php echo base_url('purchase/log/po_id/'. $purchase_order['po_id']);?>" class="form-horizontal adminex-form" method="post" accept-charset="utf-8">
                            <textarea name="info" class="form-control input-lg p-text-area" rows="2" placeholder="输入备注信息..."></textarea>
                            <footer class="panel-footer">
                                <button class="btn btn-post pull-right">批次拆分</button>
                                <button class="btn btn-post pull-right">导出采购商品</button>
                                <button type="button" name="po_status" value="3" class="btn btn-post pull-right btn-ajax">设为已完成</button>
                                <button class="btn btn-post pull-right">备注</button>
                                <ul class="nav nav-pills p-option"></ul>
                            </footer>
                        </form>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel">
                        <header class="panel-heading">
                            操作记录
                            <span class="tools pull-right">
                                        <a class="fa fa-chevron-down" href="javascript:;"></a>
                                     </span>
                        </header>
                        <div class="panel-body">
                            <ul class="activity-list">
                                <li>
                                    <div class="avatar">
                                        <img src="/public/images/photos/user1.png" alt=""/>
                                    </div>
                                    <div class="activity-desk">
                                        <h5><a href="#">Jonathan Smith</a> <span>Uploaded 5 new photos</span></h5>
                                        <p class="text-muted">7 minutes ago near Alaska, USA</p>
                                    </div>
                                </li>
                                <li>
                                    <div class="avatar">
                                        <img src="/public/images/photos/user2.png" alt=""/>
                                    </div>
                                    <div class="activity-desk">
                                        <h5><a href="#">John Doe</a> <span>Completed the Sight visit.</span></h5>
                                        <p class="text-muted">2 minutes ago near Alaska, USA</p>
                                    </div>
                                </li>

                                <li>
                                    <div class="avatar">
                                        <img src="/public/images/photos/user3.png" alt=""/>
                                    </div>
                                    <div class="activity-desk">

                                        <h5><a href="#">Jonathan Smith</a> <span>attended a meeting with</span>
                                            <a href="#">John Doe.</a></h5>
                                        <p class="text-muted">2 days ago near Alaska, USA</p>
                                    </div>
                                </li>

                                <li>
                                    <div class="avatar">
                                        <img src="/public/images/photos/user4.png" alt=""/>
                                    </div>
                                    <div class="activity-desk">

                                        <h5><a href="#">Jonathan Smith</a> <span>completed the task “wireframe design” within the dead line</span></h5>
                                        <p class="text-muted">4 days ago near Alaska, USA</p>
                                    </div>
                                </li>

                                <li>
                                    <div class="avatar">
                                        <img src="/public/images/photos/user5.png" alt=""/>
                                    </div>
                                    <div class="activity-desk">

                                        <h5><a href="#">Jonathan Smith</a> <span>was absent office due to sickness</span></h5>
                                        <p class="text-muted">4 days ago near Alaska, USA</p>
                                    </div>
                                </li>


                            </ul>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <!--body wrapper end-->

        <!--footer section start-->
        <footer class="">
            2014 &copy; AdminEx by
        </footer>
        <!--footer section end-->


    </div>
    <!-- main content end-->
</section>
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal-2" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                <h4 class="modal-title">Form Tittle</h4>
            </div>
            <div class="modal-body">
                <form class="form-inline" role="form">
                    <div class="form-group">
                        <label class="sr-only" for="exampleInputEmail2">Email address</label>
                        <input type="email" class="form-control" id="exampleInputEmail5" placeholder="Enter email">
                    </div>
                    <button type="submit" class="btn btn-primary">Sign in</button>
                </form>

            </div>

        </div>
    </div>
</div>
<?php $this->load->view('library/footer');?>

<script type="text/javascript">

    $('.input-type-multiple').on('click', function () {

        var url = $(this).attr('href');
        var sn = $(this).attr('data-sn');

        swal({
            title: '采购产品入库 - ' + sn,
            html:
            '<input id="invoice_no" placeholder="输入货架位" value="" class="swal2-input">'+
            '<input id="storage_number" placeholder="输入入库数量" value="1" class="swal2-input">',
            showCancelButton: true,
            confirmButtonText: 'Submit',
            showLoaderOnConfirm: true,
            preConfirm: function preConfirm() {
                return $.post(url, {invoice_no: $('#invoice_no').val(), storage_number: $('#storage_number').val()}, function (data) {
                    return data;
                },'json');
            },
            allowOutsideClick: false
        }).then(function (result) {
            console.log(result);
            if (result.value) {
                var data = result.value;
                swal({
                    type: data.status,
                    title: data.info
                }).then(function(isConfirm) {
                    location.reload();
                });
            }
        });
        return false;
    });

    $('.input-type-m').on('click', function () {

        var url = $(this).attr('href');
        var sn = $(this).attr('data-sn');

        swal({
            title: '输入打印数量 - ' + sn,
            html:
                '<input id="s_num" placeholder="输入入库数量" value="1" class="swal2-input">',
            showCancelButton: true,
            confirmButtonText: 'Submit',
            showLoaderOnConfirm: true,
            preConfirm: function preConfirm() {
                window.open(url+'/num/'+$('#s_num').val());
            },
            allowOutsideClick: false
        });
        return false;
    });

    $('.a-ajax').click(function () {

        var url = $(this).attr('href');

        $.get(url, {is_ajax: 1}, function (data) {
            swal({
                title: data.info,
                text: '2秒后关闭',
                type: data.status,
                allowOutsideClick: false,
                timer: data.stop ? data.stop : 1500,
                showConfirmButton: false
            }).then(function(isConfirm) {
                location.reload();
            });

        }, 'json');

        return false;
    });

    $(".btn-ajax").click(function(){
        var form = $(this).parents('form');

        var url = form.attr('action');
        var button_val = $(this).val();

        var serializeObj = form.serializeJSON()
        serializeObj.submit = button_val;


        $.post(url, serializeObj, function () {

        });


        console.log(button_val);

        return false;
    });
</script>

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>

</body>
</html>
